<?php
  include 'JHeader.php';
  require 'Database/Database.php';
  
  if(isset($_GET['id']) && isset($_GET['name']) )
  {
     $admin_id = $_GET['id'];
     $admin    = $_GET['name'];

     $db = new Database();
     $db->Connect();

     if(!$db->Select('Admins', 'JID =  ' . $admin_id))
     {
        if($db->Insert('Admins', array('JID', 'Name'), array($admin_id, $admin)))
        {
            echo $admin . ' added!';
        }
        else
        {
            echo 'Could not add ' . $admin . '!';
        }
        $db->Disconnect();
     }
     else
     {
         echo $admin . ' is already an admin.';
     }
  }
?>
<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" language="JavaScript" src="js_helpfuncs/admin_funcs.js"></script>
        <link rel="stylesheet" type="text/css" href="css/default.css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Admin hinzuf&uuml;gen</title>
    </head>
    <body>
        <h1>Admin hinzuf&uuml;gen</h1>
        <form name="add_admin">
            <div class="search">
                <b>Search:</b> <input name="admin_name" onkeyup="GetPredictions();" />
            </div>
            <div id="predictions"></div>
        </form>
    </body>
</html>
